package com.wu.shop.module.home.ui.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.wkq.lib_base.adapter.KtAdapter
import com.wu.common.base.adapter.DataBindingViewHolder
import com.wu.shop.R
import com.wu.shop.databinding.ItemHomeGoodsBinding
import com.wu.shop.module.home.frame.model.GoodsDescInfo


/**
 * @author wkq
 *
 * @date 2021年07月09日 10:40
 *
 *@des
 *
 */

class HomeGoodsAdapter (mContext:Context) :KtAdapter<GoodsDescInfo>(mContext) {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
       var viewDatabinding=DataBindingUtil.inflate<ItemHomeGoodsBinding>(LayoutInflater.from(mContext), R.layout.item_home_goods,parent,false)

        var viewHolder=DataBindingViewHolder(viewDatabinding.root)
        viewHolder.binding=viewDatabinding
        return viewHolder
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {

        var viewHolder=holder as DataBindingViewHolder
        var binding=viewHolder.binding as ItemHomeGoodsBinding


        binding.tvGoodsName.text=getItem(position)!!.goodsName
        binding.tvGoodsDesc.text=getItem(position)!!.goodsDesc
        Glide.with(mContext).load(getItem(position)!!.goodsIcon).into(binding.ivGoods)

    }


}